package com.andova.glcamera.device

import androidx.annotation.FloatRange
import com.andova.glcamera.StateCallback
import java.util.*

abstract class CameraBuilder {
    companion object {
        fun build() = object : CameraBuilder() {
            override fun previewSize(sizes: SortedSet<Size>?): Size? = null
            override fun pictureSize(sizes: SortedSet<Size>?): Size? = null
            override fun stateCallback(): StateCallback? = null
        }
    }

    var imageScale: Float = 1f
    var usePreviewCallback: Boolean = false

    @Angle
    var frameAngle: Int = ANGLE_0

    @CameraId
    var cameraId: Int = CAMERA_ID_0
    var aspectRatio: AspectRatio = ASPECT_RATIO_4_3

    fun cameraId(@CameraId id: Int): CameraBuilder = apply { cameraId = id }
    fun aspectRatio(ratio: AspectRatio): CameraBuilder = apply { aspectRatio = ratio }
    fun imageScale(@FloatRange(from = 0.1, to = 1.0) scale: Float): CameraBuilder = apply { imageScale = scale }
    fun usePreviewCallback(value: Boolean, @Angle angle: Int = ANGLE_0): CameraBuilder {
        usePreviewCallback = value
        frameAngle = angle
        return this
    }

    abstract fun previewSize(sizes: SortedSet<Size>?): Size?
    abstract fun pictureSize(sizes: SortedSet<Size>?): Size?
    abstract fun stateCallback(): StateCallback?
}